home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Resources / General / ProNET / src / utilities / pronet-run.c < prev    next >
C/C++ Source or Header  |  1996-11-30  |  2KB  |  83 lines

  1. /*
  2.     pronet-run.c
  3.  
  4. */
  5.  
  6. #include <string.h>
  7.  
  8. #include <exec/exec.h>
  9. #include <devices/pronet.h>
  10.  
  11. #include <proto/exec.h>
  12.  
  13. char verstring[] = "$VER: pronet-run 37.0 (30.11.96)";
  14.  
  15. void __chkabort(void) {}    /* Disable CTRL-C handling */
  16.  
  17. static ULONG unit = 0;
  18. static struct PNRequest *pronetio;
  19. static struct MsgPort *pronetport, *pronetport2;
  20.  
  21. #define ACTION_RUN 19941995
  22.  
  23. int main(ULONG argc, char *argv[])
  24. {
  25.     ULONG RC = 20;
  26.     BYTE pronetopen;
  27.     char string[260];
  28.  
  29.     if(argc==3)
  30.     {
  31.         unit = atoi(argv[1]);
  32.         strncpy(&string[4], argv[2], 255);
  33.         string[259] = '\0';
  34.         ((ULONG*)string)[0] = ACTION_RUN;
  35.  
  36.         if(pronetport2 = CreateMsgPort())
  37.         {
  38.             if(pronetio = (struct PNRequest*)CreateIORequest(pronetport2,sizeof(struct PNRequest)))
  39.             {
  40.                 if(pronetport = CreateMsgPort())
  41.                 {
  42.                     pronetio->pnr_NetSourcePort = PNP_NEXTFREE;
  43.                     pronetio->pnr_MsgPort = pronetport;
  44.                     pronetio->pnr_Data = &string;
  45.             
  46.                     if(!(pronetopen = OpenDevice("pronet.device",unit,(struct IORequest*)pronetio,PNF_ERRORSTRING)))
  47.                     {
  48.                         pronetio->pnr_Request.io_Command = CMD_WRITE;
  49.                         pronetio->pnr_Data = &string;        
  50.                         pronetio->pnr_Length = 260;
  51.                         pronetio->pnr_NetDestPort = 0;
  52.                         DoIO((struct IORequest*)pronetio);
  53.     
  54.                         RC = 0;
  55.                         CloseDevice((struct IORequest*)pronetio);
  56.                     }
  57.                     else switch(pronetopen)
  58.                     {
  59.                         case PNDERR_UNIT_NOT_DEFINED:
  60.                             Printf("Unit %ld not defined.\n",unit);
  61.                             break;
  62.             
  63.                         case PNDERR_DRIVERTROUBLE:
  64.                             Printf("Driver trouble: %s\n",&string);
  65.                             break;
  66.             
  67.                         default:
  68.                             Printf("Couldn't open pronet.device.\n");
  69.                             break;
  70.                     }
  71.                     DeleteMsgPort(pronetport);
  72.                 }
  73.                 DeleteIORequest((struct IORequest*)pronetio);
  74.             }
  75.             DeleteMsgPort(pronetport2);
  76.         }
  77.     }
  78.     else
  79.         Printf("Usage: pronet-run {Unit} \"{Command}\", e.g.\n       pronet-run 0 \"dir hd0: all\"\n");
  80.  
  81.     return(RC);
  82. }
  83.